"use strict";

const CleanWebpackPlugin = require("clean-webpack-plugin");
const HTMLWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const webpack = require("webpack");

module.exports = {
    context: __dirname,
    entry: [
        "./src/main.js"
    ],
    output: {
        filename: "main.js",
        path: path.resolve(__dirname, "dist"),
        publicPath: "/"
    },
    mode: "development",

    devtool: "#source-map",

    resolve: {
        extensions: [
            ".json",
            ".js"
        ]
    },
    module: {
        rules: [
            { exclude: ["node_modules"], loader: "babel-loader", test: /\.js$/ },
            { enforce: "pre", test: /\.js$/, loader: "source-map-loader" },
            { test: /\.scss$/, use: [ "style-loader", "css-loader", "sass-loader" ] }
        ]
    },
    plugins: [
        new CleanWebpackPlugin(["./dist"]),
        new HTMLWebpackPlugin({
            template: "src/index.html"
        }),
        new webpack.NoEmitOnErrorsPlugin(),
        new webpack.WatchIgnorePlugin([
            path.join(__dirname, "node_modules")
        ]),
    ],
    resolve: {
        extensions: [".js"],
        modules: [
            path.resolve(__dirname, "src"),
            "node_modules"
        ]
    },
    devServer: {
        host: "0.0.0.0"
    }
};
